import Vue from 'vue'
import App from './App.vue'
import router from './router'
// 引入全局样式表
import './assets/css/global.css'
// 引入element-ui
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
// 引入i‘vue-table-with-tree-grid’
import treeTable from 'vue-table-with-tree-grid'
Vue.component('tree-table', treeTable)

// 引入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'

import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme

Vue.use(VueQuillEditor, /* { default global options } */)

//导入加载进度条
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

// 时间过滤器
Vue.filter('dateFormat',function(val){
  let dt=new Date(val)
  let y=dt.getFullYear()
  let m=dt.getMonth()+1
  let d=dt.getDate()

  let h=dt.getHours()
  let mm=dt.getMinutes()
  let ss=dt.getMilliseconds()
  return `${y}-${m}-${d} ${h}:${mm}:${ss}`
})

// 引入axios
import axios from 'axios'
Vue.prototype.$axios=axios
axios.defaults.baseURL="http://127.0.0.1:8888/api/private/v1/"
// 设置请求拦截器
axios.interceptors.request.use(config=>{
  // 在请求头中加入token
  config.headers.Authorization=window.sessionStorage.getItem('token')
  NProgress.start()
  return config
})
axios.interceptors.response.use(config=>{
  NProgress.done()
  return config
})
Vue.config.productionTip = false
Vue.use(ElementUI)

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
